<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>medicOut</title>
    <link rel="stylesheet" href="/Trees/LayUiBac/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-container">
    <div class="layui-row">
        <form class="layui-form" action="">

            <div class="layui-form-item">
                <label class="layui-form-label">领用物品</label>
                <div class="layui-input-block">
                    <select name="medicName" id="medicName" lay-verify="required">

                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">领用数量</label>
                <div class="layui-input-block">
                    <select name="number" id="number" lay-verify="required">
                        <option value="100">100</option>
                        <option value="200">200</option>
                        <option value="300">300</option>
                        <option value="400">400</option>
                        <option value="500">500</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">用于防治</label>
                <div class="layui-input-block">
                    <select name="control" id="control" lay-verify="required">
                        <option value="鼠害">鼠害</option>
                        <option value="虫害">虫害</option>
                        <option value="病害">病害</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-block">
                    <select  id="type" name ="type" lay-verify="required">
                        <option value="器械">器械</option>
                        <option value="药械">药械</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">领用小班</label>
                <div class="layui-input-block">
                    <select name="className" id="className" lay-verify="required">

                    </select>
                </div>
            </div>

        </form>
    </div>
</div>


<script src="/Trees/LayUiBac/layui/layui.js"></script>

<script>
    //Demo
    layui.use(['form','jquery','layer'],function () {
        let form = layui.form;
        let layer = layui.layer;
        let $ = layui.$;
        form.render();
        let x ='';
        let y ='';
        $.ajax({
            type:"post"
            ,url:"/Trees/medic?method=showAllMedic"
            ,dataType:'json'
            ,success:function (data) {
                console.log(data)
                for(let i of data){
                    y+="<option value="+i.name+">"+i.name+"</option>"
                }
                $('#medicName').html(y);
                form.render('select');
            }
        })

        $.ajax({
            type:"post"
            ,url:"/Trees/classManage?method=showAllClass"
            ,dataType:'json'
            ,success:function (data) {
                console.log(data)
                for(let i of data){
                    x+="<option value="+i.pkId+">"+i.className+"</option>"
                }
                $('#className').html(x);
                form.render('select');
            }
        })

        //监听提交
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
</script>
</body>
</html>